package cn.edu.scau.cmi.wujingxuan.composite.consistent;

import java.util.ArrayList;
import java.util.Iterator;

public class Composite extends Organization
{
	private ArrayList<Organization> countryList;
	private String word = "";

	public Composite()
	{
		countryList = new ArrayList<Organization>();
	}

	public void add(Organization country)
	{
		if (country != null)
		{
			countryList.add(country);
		}
	}

	public void remove(Organization country)
	{
		if (country != null)
		{
			countryList.remove(country);
		}
	}

	public Iterator<Organization> elements()
	{
		return countryList.iterator();
	}

	public String say()
	{
		int len = countryList.size();
		for (int i = 0; i < len; i++)
		{
			Organization ctry = countryList.get(i);
			word = word + ctry.say() + "\n";
		}
		return word;
	}

	public int getSize()
	{
		return countryList.size();
	}
}